﻿#region NeoPatterns
// 
// NeoPatterns framework is released under LGPLv3 license.
// See http://www.opensource.org/licenses/lgpl-3.0.html for more details.
// 
// Please visit http://neopatterns.wikidot.com for more information about NeoPatterns
// 
// Copyright (c) Pascal Craponne 2008
// 
#endregion

using System.Diagnostics.CodeAnalysis;
using NeoPatterns.Core.Registry;
using NeoPatterns.Core.Registry.Implementation;

namespace NeoPatterns.Setup.MetaAssembly
{
    [SuppressMessage("Microsoft.Design", "CA1053:StaticHolderTypesShouldNotHaveConstructors")]
    public class MetaConfiguration
    {
        /// <summary>
        /// This ObjectRegistry is exposed to meta configuration
        /// </summary>
        public static IObjectRegistry ObjectRegistry
        {
            get { return Application.ObjectRegistry; }
        }

        static MetaConfiguration()
        {
            Application.ObjectRegistry = new ObjectRegistry();
        }

        /// <summary>
        /// Helper to ease the meta configuration writing.
        /// Inherit your classes from MetaConfiguration
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="name"></param>
        /// <returns></returns>
        public static T Ref<T>(string name)
        {
            return ObjectRegistry.Get<T>(name);
        }

        protected MetaConfiguration()
        { }
    }
}